package servlet.admin.operator;

import service.OperatorService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet( name = "AdminOperatorInsertServlet")
public class AdminOperatorInsertServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer operatorID=Integer.parseInt(request.getParameter("operatorID"));
        String name=request.getParameter("name");
        String account=request.getParameter("account");
        String password=request.getParameter("password");
        Integer character=Integer.parseInt(request.getParameter("characters"));
        String email=request.getParameter("email");
        String sex=request.getParameter("sex");
        String photo=request.getParameter("photo");

        OperatorService service=new OperatorService();
        service.insert(operatorID,name,account,password,character,email,sex,photo);

        request.getServletContext().getRequestDispatcher("AdminOperatorsServlet").forward(request, response);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
